package com.bee.bootstrap.resource.entity;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import com.bee.common.core.enums.PermissionLevelEnum;
import com.bee.common.core.enums.ResourceTypeEnum;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import javax.annotation.PostConstruct;
import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author liekkas
 * @since 2018-05-25
 */
@TableName("base_resource")
@Data
public class Resource extends Model<Resource>{

    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
	@TableId(value="id", type= IdType.ID_WORKER)
	private Long id;
    /**
     * 资源名称
     */
	private String name;
	/**
	 * 资源路径{可使用匹配符}
	 */
	private String url;
    /**
     * 资源标识符
     */
	private String code;
    /**
     * 资源类型{菜单/按钮}
     */
	private String type;
	/**
	 * 资源描述
	 */
	private String description;
    /**
     * 显示顺序
     */
	private Integer priority;
    /**
     * 父主键
     */
	@TableField("parent_id")
	private Long parentId;
    /**
     * 完整的父主键路径
     */
	@TableField("full_parent_ids")
	private String fullParentIds;
    /**
     * 权限字符串
     */
	private String permission;
    /**
     * 状态
     */
	private String status;
    /**
     * 创建时间
     */
	@TableField("create_time")
	private Date createTime;
    /**
     * 有效时间
     */
	@TableField("update_time")
	private Date updateTime;

	private transient String permissionLevel;

	private transient List<Resource> childrensView;

	private transient List<ResourceTypeEnum> resourceTypeEnums=Arrays.asList(ResourceTypeEnum.values());

	private transient List<PermissionLevelEnum> permissionLevelEnums=Arrays.asList(PermissionLevelEnum.values());
	@Override
	protected Serializable pkVal() {
		return this.id;
	}

}
